package uform.model.value;

import utest.Assert;

class TestStringType extends Test
{
	public function testParse()
	{
		var ref = { s : "" };
		var value = new StringType();
		Assert.equals('a', value.parse('"a"', ref));
		Assert.equals('a', value.parse('a', ref));
		Assert.equals('a', value.parse('"a","b"', ref));
		Assert.equals('a', value.parse("'a','b'", ref));
		Assert.equals('a"b', value.parse('"a\\"b",c', ref));
		Assert.equals('a"b"c', value.parse('"a\\"b\\"c","d"', ref));
	}
	
	public function testValidateType()
	{
		var value = new StringType();
		assertValidation(value.validateType(""), true);
		assertValidation(value.validateType("x"), true);
		assertValidation(value.validateType(-1), false);
		assertValidation(value.validateType(true), false);
	}
	
	public function new();
}